In order to allow building as non-root with a non-default CC (which
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Tue, 27 Mar 2007 13:50:17 +0000 (14:50 +0100)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Tue, 27 Mar 2007 13:50:17 +0000 (14:50 +0100)
root may not have access to through its $PATH), defer the generation
of an error until CC is actually needed.

Original patch by Jan Beulich <jbeulich@novell.com>

Signed-off-by: Keir Fraser <keir@xensource.com>
Config.mk
tools/Rules.mk
xen/arch/x86/Rules.mk
xen/include/public/foreign/Makefile

index 0181cc3ad12c8890acea471a732aab8b87176444..57d17740adb8356feb69ea834a65557bb6e37145 100644 (file)
--- a/Config.mk
+++ b/Config.mk
@@ -31,17 +31,27 @@ EXTRA_INCLUDES += $(EXTRA_PREFIX)/include
 EXTRA_LIB += $(EXTRA_PREFIX)/$(LIBDIR)
 endif
 
-# cc-option
+# cc-option: Check if compiler supports first option, else fall back to second.
 # Usage: cflags-y += $(call cc-option,$(CC),-march=winchip-c6,-march=i586)
 cc-option = $(shell if test -z "`$(1) $(2) -S -o /dev/null -xc \
               /dev/null 2>&1`"; then echo "$(2)"; else echo "$(3)"; fi ;)
 
-# cc-ver
+# cc-ver: Check compiler is at least specified version. Return boolean 'y'/'n'.
 # Usage: ifeq ($(call cc-ver,$(CC),0x030400),y)
 cc-ver = $(shell if [ $$((`$(1) -dumpversion | awk -F. \
            '{ printf "0x%02x%02x%02x", $$1, $$2, $$3}'`)) -ge $$(($(2))) ]; \
            then echo y; else echo n; fi ;)
 
+# cc-ver-check: Check compiler is at least specified version, else fail.
+# Usage: $(call cc-ver-check,CC,0x030400,"Require at least gcc-3.4")
+cc-ver-check = $(eval $(call cc-ver-check-closure,$(1),$(2),$(3)))
+define cc-ver-check-closure
+    ifeq ($$(call cc-ver,$$($(1)),$(2)),n)
+        override $(1) = echo "*** FATAL BUILD ERROR: "$(3) >&2; exit 1;
+        cc-option := n
+    endif
+endef
+
 ifneq ($(debug),y)
 CFLAGS += -DNDEBUG
 else
index 3e13eceb553a22824929b839ed4abb664786ac4e..e087c94dd4189c4246f4122c9700955f06b2b88e 100644 (file)
@@ -24,9 +24,9 @@ CFLAGS-$(CONFIG_X86_32) += $(call cc-option,$(CC),-mno-tls-direct-seg-refs)
 CFLAGS += $(CFLAGS-y)
 
 # Require GCC v3.4+ (to avoid issues with alignment constraints in Xen headers)
-ifeq ($(CONFIG_X86)$(call cc-ver,$(CC),0x030400),yn)
-$(error Xen tools require at least gcc-3.4)
-endif
+check-$(CONFIG_X86) = $(call cc-ver-check,CC,0x030400,\
+                        "Xen requires at least gcc-3.4")
+$(eval $(check-y))
 
 %.opic: %.c
        $(CC) $(CPPFLAGS) -DPIC $(CFLAGS) -fPIC -c -o $@ $<
index 86b9f33ab191fd93ddaf87bb6462c4a4387b7708..97e376a4ab53cfb415259ad20f52e60ddbd598de 100644 (file)
@@ -59,6 +59,4 @@ HDRS += $(wildcard $(BASEDIR)/include/asm-x86/hvm/svm/*.h)
 HDRS += $(wildcard $(BASEDIR)/include/asm-x86/hvm/vmx/*.h)
 
 # Require GCC v3.4+ (to avoid issues with alignment constraints in Xen headers)
-ifneq ($(call cc-ver,$(CC),0x030400),y)
-$(error Xen requires at least gcc-3.4)
-endif
+$(call cc-ver-check,CC,0x030400,"Xen requires at least gcc-3.4")
index c107c5ab7f67d72151d89d43b64b2f656a2cc503..b16c3efec154d80d3458c58b152ecf71d5cb6d13 100644 (file)
@@ -1,5 +1,5 @@
-XEN_ROOT := ../../../..
-include $(XEN_ROOT)/tools/Rules.mk
+XEN_ROOT=../../../..
+include $(XEN_ROOT)/Config.mk
 
 architectures := x86_32 x86_64 ia64
 headers := $(patsubst %, %.h, $(architectures))